home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / comm / tlx_sq21.zip / DNLOAD.SLT < prev    next >
Text File  |  1992-03-20  |  26KB  |  771 lines

  1. //-----------------------------------------------------------
  2. // DNLOAD.SL? Automatic download from BBS systems.
  3.  
  4. str dll_file [] = "DOWNLOAD";    // Download log file.
  5. str filelist [] = "FILELIST.BBS";// Name of file containing filenames.
  6. int MinLeft = 5;                 // Minimum time left for download.
  7.  
  8. //-----------------------------------------------------------
  9. // The file <BBS>.DL must be placed in TELIX's program (main)
  10. // directory. <BBS> consists of the first 8 (max.) alphabetic
  11. // characters of the BBS name.
  12. // The following parameters must be defined in this file:
  13.  
  14. // Filename to download.
  15. // Filename to download
  16. // etc.
  17.  
  18. // Example:
  19.  
  20. // GAME1.ZIP
  21. // GAME2.ZIP
  22. // GRAPHICS.ZIP
  23.  
  24. // You may specify as many files as you want. However, the
  25. // script attempts to download only 10 files. The script does
  26. // not attempt to download files that are already in the download
  27. // directory. Thus you may run the script repeatedly to download
  28. // more files (if you have enough file time) without having to
  29. // modify the specification file manually.
  30.  
  31. // These files are downloaded to the directory defined for
  32. // this purpose in TELIX. You may NOT specify directory
  33. // (path) in the download specifications.
  34.  
  35. // Hint: Define a softkey to trigger this file (define in NAME.DAT)
  36. //-----------------------------------------------------------
  37.  
  38. // If you have suggestions for improving this script, please suggest
  39. // improvements to me via old-fashioned snail-mail to:
  40.  
  41. // Author:  Inge Vabekk
  42. //          Hamangskogen 108
  43. //          N-1300 SANDVIKA
  44. //          NORWAY
  45. //          tel. (472) 546 396
  46.  
  47. str dls_file [14]            // Download specifications 
  48.    ,NextConf [14]            // Next conference
  49.    ,PrevConf [14]            // Previous conference
  50.    ,filist   [30]            // Name of filelist.
  51.    ,myprot    [2]            // "My" protocol
  52.    ,hisprot   [2]            // The BBS's protocol
  53.    ,shortname [8]            // Short name of BBS.
  54.    ,input   [144]            // Input line.
  55.    ,f0       [14]            // Filename for download.
  56.    ,command  [10]            // Command prompt.
  57.    ,temp      [4]            // Temporary for short strings.
  58.    ,password [14]            // Password for file download.
  59.                              // For the Global storage:
  60.    ,global   []="GLOBAL"     // Global script.
  61.    ,PutLine  []="PUTLINE"    // Put Line script.
  62.    ,UpDownF  []="UPDOWNF"    // Upload/Download script.
  63.    ,bbsname  []="BNAME"      // BBS name.
  64.    ,bbstype  []="BTYPE"      // BBS type.
  65.    ,short    []="SHORT"      // Short BBS name.
  66.    ,Cprot    []="CPROT"      // Current protocol.
  67.    ,Hprot    []="HPROT"      // "His" protocol.
  68.    ,version  []="BBSver"     // PCB version
  69.    ,conf     []="CONF"       // Current conference
  70.    ,ConfList []="CNFLST"     // YES if conference list wanted.
  71.    ,prompt   []="PROMPT"     // Current command prompt.
  72.    ,maxdn    []="MAXDN"      // Max. files for download.
  73.    ,fpass    []="FPASS"      // Password for downloading.
  74.    ;     
  75.  
  76. // Other constants and variables.
  77.  
  78. int tol = 300      // timeout limit 30 sec.
  79.    ,tmark, stat
  80.    ,mbbs, pcb, rbbs, opus, fido, crcs    // Possible BBS types
  81.    ,BBSver         // PCBoard version.
  82.    ,infile         // Input file pointer
  83.    ,infilemenu     // TRUE if in file menu
  84.    ,success        // Count of succesful downloads.
  85.    ,fail = 0       // Number of failures.
  86.    ,MAX            // Max # files to download 
  87.    ,MORE           // More files to download 
  88.    ,switched       // TRUE (1) if conferences switched.
  89.    ,protocol       // Must be INT.
  90.    ,error          // General error indicator
  91.    ,Enter = 13     // Code for CR.
  92.    ;
  93.  
  94. //-----------------------------------------------------------
  95. // DNload script starts here.
  96. //-----------------------------------------------------------
  97.  
  98. main()
  99. {
  100. int c, i, k;               // Temporary storage.   
  101.  
  102.   entry();                               // Updates colors & status bar. 
  103.  
  104. // Check if online.
  105. //-----------------------------------------------------------
  106.  
  107.   if (!carrier())   
  108.   { tone (150,50);                       // No, failure.
  109.     status_wind ("T²: YOU CAN ONLY DOWNLOAD IF YOU'RE ONLINE!",20);
  110.     return (-1);
  111.   }
  112.   
  113. // Find BBS type (Set one logical variable).
  114.  
  115.   read (bbstype,input);                  // Get BBS type,
  116.  
  117.   mbbs = pcb = rbbs = opus = fido = crcs = 0;
  118.   if      (input == "MBBS") mbbs = 1;
  119.   else if (input == "PCB" ) pcb  = 1;
  120.   else if (input == "RBBS") rbbs = 1;
  121.   else if (input == "OPUS") opus = 1;
  122.   else if (input == "FIDO") fido = 1;
  123.   else if (input == "CRCS") crcs = 1;
  124.   else                                          
  125.   { wrongBBS(input);                     // Doesn't match script!
  126.     return (-1);
  127.   }
  128.   read (version,temp);
  129.   BBSver = subchr (temp,0);              // BBS version.
  130.  
  131.   read (prompt,command);                 // Get command prompt.
  132.   read (cprot,myprot);                   // Protocol.
  133.   protocol = toupper(subchr(myprot,0));
  134.   read (hprot,hisprot);                  // His protocol.
  135.   if (pcb) NextConf = "Main Board";      // Join Main conference.
  136.   read (conf,PrevConf);                  // Get current conference.
  137.   switched = 0;
  138.  
  139.   read (short,shortname);                // Get the short name and build
  140.   dls_file = shortname;                  // name of download spec. file.
  141.   strcat (dls_file,".DL");               // Add extension.
  142.  
  143.   newdir (_telix_dir);                   // Go back to TELIX directory.
  144.   infile = filesize(dls_file);           // Check if download file exists.
  145.   if (infile < 0)                        // If not,
  146.   { if (!timeleft(MinLeft))
  147.       return (99);                       // Not enough time left.
  148.   
  149.     exec ("HAVEIT$",shortname);          // run program to build it.
  150.     infile = filesize(dls_file);         // Check result.
  151.   }
  152.   else if (!timeleft(MinLeft))
  153.       goto done;                         // Not enough time left.
  154.  
  155.   if (infile > 0)
  156.     infile = fopen (dls_file,"r");       // Open file for READ.
  157.  
  158.   if (infile <= 0) goto done;            // No file???
  159.  
  160.   read (maxdn,temp);
  161.   MORE = MAX = stoi (temp);              // Max. files to download.
  162.  
  163.   success = 0;                           // No files so far.
  164.  
  165.   infilemenu = 0;                        // NOT in file menu yet.
  166.   while ((error=fgets (input,144,infile)) > 0  // Download files.
  167.          && MORE
  168.          && success < MAX 
  169.          && carrier()
  170.          && strlen(input) > 3            // Sensible input
  171.          && timeleft(MinLeft))
  172.   { k = -1;
  173.     for (i=0; (c=subchr(input,i)) > 0; ++i)
  174.     { c = toupper(c);
  175.       if (c > ' ')
  176.       { if (k < 0)                       // First character:
  177.         { if (c=='#' || c=='+' || c=='-' || c=='&')
  178.             continue;
  179.         }
  180.         setchr (f0,++k,c);               // ANY char. > space)
  181.       }
  182.       else if (k > 1)
  183.         break;                           // Filename ended.
  184.     }
  185.     setchr (f0,++k,0);                   // End of string.
  186.  
  187.     for(i=0; (c=subchr(input,i))<=' '; ++i)
  188.       if (!c) goto loop1;                // Find first character.
  189.  
  190.     if (c=='#' || c =='+' || c=='-')     // Change conference?
  191.     { substr (input,++i,14,NextConf);    // Copy conference name.
  192.       setconf(c);                        // Set conference.
  193.     }
  194.     else if (c=='&')                     // Password?
  195.     { substr (input,++i,14,password);    // Copy password.
  196.       write (fpass,password);            // Update password.
  197.     }
  198.     else
  199.       if (k > 1) DL();                   // Download this file....
  200.      
  201. loop1:
  202.     continue;
  203.   }                                      // Read next input line.
  204.  
  205.   fclose (infile);                       // Close the command file. 
  206.  
  207. done:
  208.   fdelete (dls_file);
  209.   if (!carrier()) return (-1);
  210.   if (!timeleft(MinLeft))
  211.     return (99);                         // No more time left.
  212.   return(0);
  213. }
  214.  
  215. //-----------------------------------------------------------
  216. // Download one file. All systems.
  217. //---------------------------------------------------------